//
//  CZSrStatusViewCell.swift
//  GZWeibo666
//
//  Created by  sr on 15/12/1.
//  Copyright © 2015年 itcast. All rights reserved.
//

import UIKit

class CZSrCommentViewCell: UITableViewCell {
    var status: CZStatus?

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        prepareUI()
        
    
      }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

     func prepareUI() {
        contentView.addSubview(iconView)
        contentView.addSubview(nameLabel)
        contentView.addSubview(timeLabel)
        contentView.addSubview(mbrankImageView)
        contentView.addSubview(commentLabel)
        //约束
        iconView.ff_AlignInner(type: ff_AlignType.TopLeft, referView: contentView, size: CGSize(width: 35, height: 35), offset: CGPoint(x: CZStatusCellMargin, y: CZStatusCellMargin))
        
        /// 用户名称
        nameLabel.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: iconView, size: nil, offset: CGPoint(x: CZStatusCellMargin, y: 0))
        /// 会员图标
        mbrankImageView.ff_AlignHorizontal(type: ff_AlignType.CenterRight, referView: nameLabel, size: CGSize(width: 14, height: 14), offset: CGPoint(x: CZStatusCellMargin, y: 0))
        
        /// 时间
        timeLabel.ff_AlignHorizontal(type: ff_AlignType.BottomRight, referView: iconView, size: nil, offset: CGPoint(x: CZStatusCellMargin, y: 0))
        //评论
        commentLabel.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: timeLabel, size: CGSize(width: UIScreen.mainScreen().bounds.width - CGRectGetMinX(timeLabel.frame), height: 20), offset: CGPoint(x: 0, y: CZStatusCellMargin))
        contentView.addConstraint(NSLayoutConstraint(item: contentView, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: commentLabel, attribute: NSLayoutAttribute.Bottom, multiplier: 1.0, constant: 0))
       
    }
   //懒加载
    //图片
    private lazy var iconView: UIImageView = {
       let view = UIImageView()
        return view
    }()
    //名字
    private lazy var nameLabel: UILabel = UILabel(color: UIColor.blackColor(), fontSize: 14)
    //时间
    private lazy var timeLabel: UILabel = UILabel(color: UIColor.orangeColor(), fontSize: 9)
    /// 会员等级图标
    private lazy var mbrankImageView: UIImageView = UIImageView()
    //评论内容
    private lazy var commentLabel: UILabel = {
       let label = UILabel()
        label.textColor = UIColor.blackColor()
        label.font = UIFont.systemFontOfSize(14)
        label.numberOfLines = 0
        return label
    }()
    
    
}
